<template>
      <div>
        手机
        接参数：{{id}}
        <br>
        <h1>注册</h1>
        <div id="app">
          <div style="width:50%" class="container">
            <div>
              <h3>Regist</h3>
              <h5>username</h5>
              <input type="text" class="form-control" v-model="user.username" /><br />
              {{user.username}}
              <h5>birthday</h5>
              <input type="text" class="form-control" v-model="user.birthday" /><br />
              <h5>Password</h5>
              <input type="password" class="form-control" v-model="user.password" /><br />
              {{user.password}}
              <h5>Gender</h5>
              <input type="radio" name="gender" v-model="user.gender" value="1" />男
              <input type="radio" name="gender" v-model="user.gender" value="0" />女<br />
              {{user.gender}}
              <h5>Hobby</h5>
              <input type="checkbox" name="hobby" v-model="user.hobby" value="music">音乐
              <input type="checkbox" name="hobby" v-model="user.hobby" value="movie">电影
              <input type="checkbox" name="hobby" v-model="user.hobby" value="sport">运动
              {{user.hobby}}
              <br/>
              <button type="button" class="btn btn-success" @click="registfn">注册</button>
            </div>
          </div>
        </div>


      </div>
</template>

<script>
    export default {
        name: "Phone",
        data(){
           return {id:this.$route.params.id,user:{hobby:[],birthday:"2010-01-01 01:01:01"}}
        },
      methods:{
        registfn(){
         // $.ajax({});
         //axios异步请求
          this.$axios({
            url:"http://localhost:8088/users",
            data:this.user,
            method:"POST"
          }).
            //异步请求成功后的回调函数
          then(function(r){
            console.log(r);
            //r.data
             if(r.data.code==0){
               alert('注册成功！！');
             }
          });

        }
      }
    }
</script>

<style scoped>

</style>
